<?php

use yii\db\Schema;
use yii\db\Migration;

class m150107_080042_add_rpt_tables extends Migration
{
    public function up()
    {
		$sql = <<<FINE
-- ----------------------------
-- Table structure for {{%rpt_sumadbyday}}
-- ----------------------------
DROP TABLE IF EXISTS {{%rpt_sumadbyday}};
CREATE TABLE {{%rpt_sumadbyday}} (
  id int(11) NOT NULL AUTO_INCREMENT,
  distributiontype int(11) DEFAULT '0',
  logfrom int(11) DEFAULT '0' COMMENT '0 is ad,1 is video',
  adspaceid bigint(20) DEFAULT '0',
  solutionid int(11) DEFAULT '0',
  creativeuuid varchar(200) DEFAULT NULL,
  exchangeid int(11) DEFAULT '0',
  dealid int(11) DEFAULT '0',
  campaign_id int(11) DEFAULT '0',
  seller_name varchar(40) DEFAULT NULL,
  adspace_name varchar(40) DEFAULT NULL,
  base_price varchar(32) DEFAULT '0',
  solution_name varchar(40) DEFAULT NULL,
  advertiser_id int(11) DEFAULT '0',
  campaign_name varchar(40) DEFAULT NULL,
  advertiser_name varchar(40) DEFAULT NULL,
  creative_name varchar(40) DEFAULT NULL,
  reqs int(11) DEFAULT '0',
  bids int(11) DEFAULT '0',
  shows int(11) DEFAULT '0',
  origin_cost decimal(24,10) DEFAULT '0.0000000000',
  cost decimal(24,10) DEFAULT '0.0000000000',
  clicks int(11) DEFAULT '0',
  logdate date NOT NULL,
  logdate_id int(11) NOT NULL,
  quarter int(11) NOT NULL,
  week int(11) NOT NULL,
  month int(11) NOT NULL,
  flag int(11) DEFAULT '0',
  tableFlag int(11) DEFAULT '0',
  dbflag int(11) DEFAULT '0',
  created datetime NOT NULL,
  modified datetime NOT NULL,
  creator int(1) NOT NULL DEFAULT '1',
  creator_name varchar(64) DEFAULT NULL,
  label_id int(11) NOT NULL DEFAULT '0',
  campaign_label_name varchar(64) DEFAULT NULL,
  PRIMARY KEY (id),
  KEY idx_hour_tongji (logdate_id,distributiontype,logfrom,adspaceid,creativeuuid,solutionid,dealid,exchangeid) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=64 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for {{%rpt_sumadbyhour}}
-- ----------------------------
DROP TABLE IF EXISTS {{%rpt_sumadbyhour}};
CREATE TABLE {{%rpt_sumadbyhour}} (
  id int(11) NOT NULL AUTO_INCREMENT,
  distributiontype int(11) DEFAULT '0',
  logfrom int(11) DEFAULT '0' COMMENT '0 is ad,1 is video',
  adspaceid bigint(20) DEFAULT '0',
  solutionid int(11) DEFAULT '0',
  creativeuuid varchar(200) DEFAULT NULL,
  exchangeid int(11) DEFAULT '0',
  dealid int(11) DEFAULT '0',
  campaign_id int(11) DEFAULT '0',
  seller_name varchar(40) DEFAULT NULL,
  adspace_name varchar(40) DEFAULT NULL,
  base_price varchar(32) DEFAULT '0',
  solution_name varchar(40) DEFAULT NULL,
  advertiser_id int(11) DEFAULT '0',
  campaign_name varchar(40) DEFAULT NULL,
  advertiser_name varchar(40) DEFAULT NULL,
  creative_name varchar(40) DEFAULT NULL,
  reqs int(11) DEFAULT '0',
  bids int(11) DEFAULT '0',
  shows int(11) DEFAULT '0',
  origin_cost decimal(24,10) DEFAULT '0.0000000000',
  cost decimal(24,10) DEFAULT '0.0000000000',
  clicks int(11) DEFAULT '0',
  logdate date NOT NULL,
  logdate_id int(11) NOT NULL,
  loghour int(11) NOT NULL,
  quarter int(11) NOT NULL,
  week int(11) NOT NULL,
  month int(11) NOT NULL,
  flag int(11) DEFAULT '0',
  tableFlag int(11) DEFAULT '0',
  dbflag int(11) DEFAULT '0',
  created datetime NOT NULL,
  modified datetime NOT NULL,
  creator int(1) NOT NULL DEFAULT '1',
  creator_name varchar(64) DEFAULT NULL,
  label_id int(11) NOT NULL DEFAULT '0',
  campaign_label_name varchar(64) DEFAULT NULL,
  PRIMARY KEY (id),
  KEY idx_hour_tongji (logdate_id,distributiontype,logfrom,adspaceid,creativeuuid,solutionid,dealid,exchangeid) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=121 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for {{%rpt_sumregionbyday}}
-- ----------------------------
DROP TABLE IF EXISTS {{%rpt_sumregionbyday}};
CREATE TABLE {{%rpt_sumregionbyday}} (
  id int(11) NOT NULL AUTO_INCREMENT,
  distributiontype int(11) DEFAULT '0',
  logfrom int(11) DEFAULT '0' COMMENT '0 is ad,1 is video',
  solutionid int(11) DEFAULT '0',
  creativeuuid varchar(200) DEFAULT NULL,
  exchangeid int(11) DEFAULT '0',
  dealid int(11) DEFAULT '0',
  campaign_id int(11) DEFAULT '0',
  region varchar(20) DEFAULT '00000000',
  country char(40) DEFAULT NULL,
  cn char(20) DEFAULT NULL,
  cn_city char(20) DEFAULT NULL,
  seller_name varchar(40) DEFAULT NULL,
  solution_name varchar(40) DEFAULT NULL,
  advertiser_id int(11) DEFAULT '0',
  campaign_name varchar(40) DEFAULT NULL,
  advertiser_name varchar(40) DEFAULT NULL,
  creative_name varchar(40) DEFAULT NULL,
  reqs int(11) DEFAULT '0',
  bids int(11) DEFAULT '0',
  shows int(11) DEFAULT '0',
  origin_cost decimal(24,10) DEFAULT '0.0000000000',
  cost decimal(24,10) DEFAULT '0.0000000000',
  clicks int(11) DEFAULT '0',
  logdate date NOT NULL,
  logdate_id int(11) NOT NULL,
  quarter int(11) NOT NULL,
  week int(11) NOT NULL,
  month int(11) NOT NULL,
  flag int(11) DEFAULT '0',
  tableFlag int(11) DEFAULT '0',
  dbflag int(11) DEFAULT '0',
  created datetime NOT NULL,
  modified datetime NOT NULL,
  creator int(1) NOT NULL DEFAULT '1',
  creator_name varchar(64) DEFAULT NULL,
  label_id int(11) NOT NULL DEFAULT '0',
  campaign_label_name varchar(64) DEFAULT NULL,
  PRIMARY KEY (id),
  KEY idx_hour_tongji (logdate_id,distributiontype,logfrom,creativeuuid,solutionid,dealid,region,exchangeid) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=55 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for {{%rpt_sumregionbyhour}}
-- ----------------------------
DROP TABLE IF EXISTS {{%rpt_sumregionbyhour}};
CREATE TABLE {{%rpt_sumregionbyhour}} (
  id int(11) NOT NULL AUTO_INCREMENT,
  distributiontype int(11) DEFAULT '0',
  logfrom int(11) DEFAULT '0' COMMENT '0 is ad,1 is video',
  solutionid int(11) DEFAULT '0',
  creativeuuid varchar(200) DEFAULT NULL,
  exchangeid int(11) DEFAULT '0',
  dealid int(11) DEFAULT '0',
  campaign_id int(11) DEFAULT '0',
  region varchar(20) DEFAULT '00000000',
  country char(40) DEFAULT NULL,
  cn char(20) DEFAULT NULL,
  cn_city char(20) DEFAULT NULL,
  seller_name varchar(40) DEFAULT NULL,
  solution_name varchar(40) DEFAULT NULL,
  advertiser_id int(11) DEFAULT '0',
  campaign_name varchar(40) DEFAULT NULL,
  advertiser_name varchar(40) DEFAULT NULL,
  creative_name varchar(40) DEFAULT NULL,
  reqs int(11) DEFAULT '0',
  bids int(11) DEFAULT '0',
  shows int(11) DEFAULT '0',
  origin_cost decimal(24,10) DEFAULT '0.0000000000',
  cost decimal(24,10) DEFAULT '0.0000000000',
  clicks int(11) DEFAULT '0',
  logdate date NOT NULL,
  logdate_id int(11) NOT NULL,
  loghour int(11) NOT NULL,
  quarter int(11) NOT NULL,
  week int(11) NOT NULL,
  month int(11) NOT NULL,
  flag int(11) DEFAULT '0',
  tableFlag int(11) DEFAULT '0',
  dbflag int(11) DEFAULT '0',
  created datetime NOT NULL,
  modified datetime NOT NULL,
  creator int(1) NOT NULL DEFAULT '1',
  creator_name varchar(64) DEFAULT NULL,
  label_id int(11) NOT NULL DEFAULT '0',
  campaign_label_name varchar(64) DEFAULT NULL,
  PRIMARY KEY (id),
  KEY idx_hour_tongji (logdate_id,distributiontype,logfrom,creativeuuid,solutionid,dealid,region,exchangeid) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

FINE;
		$this->execute($sql);
    }

    public function down()
    {
		$sql = <<<FINE
DROP TABLE IF EXISTS {{%rpt_sumregionbyhour}};
DROP TABLE IF EXISTS {{%rpt_sumregionbyday}};
DROP TABLE IF EXISTS {{%rpt_sumadbyhour}};
DROP TABLE IF EXISTS {{%rpt_sumadbyday}};
FINE;
		$this->execute($sql);

        return false;
    }
}
